package com.example.shop.scollview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private RelativeLayout mLayoutContainer;
    int count=0;
    TextView lastTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mLayoutContainer = (RelativeLayout) findViewById(R.id.layout_container);
    }

    public void go1(View v) {
        Button textView= (Button) this.getLayoutInflater().inflate(R.layout.item_navi,mLayoutContainer,false);
        textView.setText("当前是： "+count++);
        if (lastTextView!=null) {
            RelativeLayout.LayoutParams layoutParams= (RelativeLayout.LayoutParams) textView.getLayoutParams();
            layoutParams.leftMargin=lastTextView.getRight()-55;
            textView.setLayoutParams(layoutParams);
        }
        //总是把最后加载的设置为第0个。
        mLayoutContainer.addView(textView,0);
        lastTextView=textView;
    }

    public void go2(View v) {


    }

    public void go3(View v) {


    }

}
